package org.ccay.core.orm.impl;

import javax.inject.Named;

import org.ccay.core.exception.IExceptionConverter;
import org.ccay.core.orm.ValueTooLargerException;

/**
 * 未知SQL异常转换器	
 * 
 * @since 2012-2-15
 */
@Named("IExceptionConverter.org.springframework.jdbc.UncategorizedSQLException")
public class UncategorizedSQLExceptionConverter implements IExceptionConverter {

	private static final String ORACLE_TOO_LARGER_VALUE = "ORA-12899";

	/* (non-Javadoc)
	 * @see org.ccay.core.exception.IExceptionConverter#convert(java.lang.Throwable)
	 */
	public Throwable convert(Throwable originalException) {
		String message = originalException.getMessage();
		if(message.indexOf(ORACLE_TOO_LARGER_VALUE)!=-1){
			return new ValueTooLargerException(originalException);
		}
		
		return originalException;		
	}

}
